<?php

/**
 * Clientorder filter form base class.
 *
 * @package    symfony
 * @subpackage filter
 * @author     Your name here
 */
abstract class BaseClientorderFormFilter extends BaseFormFilterPropel
{
  public function setup()
  {
    $this->setWidgets(array(
      'orderName'                => new sfWidgetFormFilterInput(array('with_empty' => false)),
      'textCategoryId'           => new sfWidgetFormPropelChoice(array('model' => 'Textcategories', 'add_empty' => true)),
      'targetGroupId'            => new sfWidgetFormPropelChoice(array('model' => 'Targetgroup', 'add_empty' => true)),
      'formalStyleId'            => new sfWidgetFormPropelChoice(array('model' => 'Formalstyle', 'add_empty' => true)),
      'personStyleId'            => new sfWidgetFormPropelChoice(array('model' => 'Personstyle', 'add_empty' => true)),
      'emotionStyleId'           => new sfWidgetFormPropelChoice(array('model' => 'Emotionstyle', 'add_empty' => true)),
      'formulateId'              => new sfWidgetFormPropelChoice(array('model' => 'Formulatetext', 'add_empty' => true)),
      'excludedWords'            => new sfWidgetFormFilterInput(),
      'urlImage'                 => new sfWidgetFormFilterInput(),
      'created_at'               => new sfWidgetFormFilterDate(array('from_date' => new sfWidgetFormDate(), 'to_date' => new sfWidgetFormDate())),
      'expires_at'               => new sfWidgetFormFilterDate(array('from_date' => new sfWidgetFormDate(), 'to_date' => new sfWidgetFormDate())),
      'updated_at'               => new sfWidgetFormFilterDate(array('from_date' => new sfWidgetFormDate(), 'to_date' => new sfWidgetFormDate())),
      'editionoptionsorder_list' => new sfWidgetFormPropelChoice(array('model' => 'Editionoptions', 'add_empty' => true)),
      'optionalgroupsorder_list' => new sfWidgetFormPropelChoice(array('model' => 'Optionaltargetgroups', 'add_empty' => true)),
      'ordermedia_list'          => new sfWidgetFormPropelChoice(array('model' => 'Media', 'add_empty' => true)),
      'structureorder_list'      => new sfWidgetFormPropelChoice(array('model' => 'Structure', 'add_empty' => true)),
    ));

    $this->setValidators(array(
      'orderName'                => new sfValidatorPass(array('required' => false)),
      'textCategoryId'           => new sfValidatorPropelChoice(array('required' => false, 'model' => 'Textcategories', 'column' => 'idTextCategories')),
      'targetGroupId'            => new sfValidatorPropelChoice(array('required' => false, 'model' => 'Targetgroup', 'column' => 'idTargetGroup')),
      'formalStyleId'            => new sfValidatorPropelChoice(array('required' => false, 'model' => 'Formalstyle', 'column' => 'idFormalStyle')),
      'personStyleId'            => new sfValidatorPropelChoice(array('required' => false, 'model' => 'Personstyle', 'column' => 'idPersonStyle')),
      'emotionStyleId'           => new sfValidatorPropelChoice(array('required' => false, 'model' => 'Emotionstyle', 'column' => 'idEmotionStyle')),
      'formulateId'              => new sfValidatorPropelChoice(array('required' => false, 'model' => 'Formulatetext', 'column' => 'idFormulateText')),
      'excludedWords'            => new sfValidatorPass(array('required' => false)),
      'urlImage'                 => new sfValidatorPass(array('required' => false)),
      'created_at'               => new sfValidatorDateRange(array('required' => false, 'from_date' => new sfValidatorDate(array('required' => false)), 'to_date' => new sfValidatorDate(array('required' => false)))),
      'expires_at'               => new sfValidatorDateRange(array('required' => false, 'from_date' => new sfValidatorDate(array('required' => false)), 'to_date' => new sfValidatorDate(array('required' => false)))),
      'updated_at'               => new sfValidatorDateRange(array('required' => false, 'from_date' => new sfValidatorDate(array('required' => false)), 'to_date' => new sfValidatorDate(array('required' => false)))),
      'editionoptionsorder_list' => new sfValidatorPropelChoice(array('model' => 'Editionoptions', 'required' => false)),
      'optionalgroupsorder_list' => new sfValidatorPropelChoice(array('model' => 'Optionaltargetgroups', 'required' => false)),
      'ordermedia_list'          => new sfValidatorPropelChoice(array('model' => 'Media', 'required' => false)),
      'structureorder_list'      => new sfValidatorPropelChoice(array('model' => 'Structure', 'required' => false)),
    ));

    $this->widgetSchema->setNameFormat('clientorder_filters[%s]');

    $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);

    parent::setup();
  }

  public function addEditionoptionsorderListColumnCriteria(Criteria $criteria, $field, $values)
  {
    if (!is_array($values))
    {
      $values = array($values);
    }

    if (!count($values))
    {
      return;
    }

    $criteria->addJoin(EditionoptionsorderPeer::IDORDER, ClientorderPeer::IDORDER);

    $value = array_pop($values);
    $criterion = $criteria->getNewCriterion(EditionoptionsorderPeer::IDEDITIONOPTION, $value);

    foreach ($values as $value)
    {
      $criterion->addOr($criteria->getNewCriterion(EditionoptionsorderPeer::IDEDITIONOPTION, $value));
    }

    $criteria->add($criterion);
  }

  public function addOptionalgroupsorderListColumnCriteria(Criteria $criteria, $field, $values)
  {
    if (!is_array($values))
    {
      $values = array($values);
    }

    if (!count($values))
    {
      return;
    }

    $criteria->addJoin(OptionalgroupsorderPeer::IDCLIENTORDER, ClientorderPeer::IDORDER);

    $value = array_pop($values);
    $criterion = $criteria->getNewCriterion(OptionalgroupsorderPeer::IDOPTIONALTARGET, $value);

    foreach ($values as $value)
    {
      $criterion->addOr($criteria->getNewCriterion(OptionalgroupsorderPeer::IDOPTIONALTARGET, $value));
    }

    $criteria->add($criterion);
  }

  public function addOrdermediaListColumnCriteria(Criteria $criteria, $field, $values)
  {
    if (!is_array($values))
    {
      $values = array($values);
    }

    if (!count($values))
    {
      return;
    }

    $criteria->addJoin(OrdermediaPeer::IDCLIENTORDER, ClientorderPeer::IDORDER);

    $value = array_pop($values);
    $criterion = $criteria->getNewCriterion(OrdermediaPeer::IDTEXTMEDIA, $value);

    foreach ($values as $value)
    {
      $criterion->addOr($criteria->getNewCriterion(OrdermediaPeer::IDTEXTMEDIA, $value));
    }

    $criteria->add($criterion);
  }

  public function addStructureorderListColumnCriteria(Criteria $criteria, $field, $values)
  {
    if (!is_array($values))
    {
      $values = array($values);
    }

    if (!count($values))
    {
      return;
    }

    $criteria->addJoin(StructureorderPeer::IDORDER, ClientorderPeer::IDORDER);

    $value = array_pop($values);
    $criterion = $criteria->getNewCriterion(StructureorderPeer::IDSTRUCTURE, $value);

    foreach ($values as $value)
    {
      $criterion->addOr($criteria->getNewCriterion(StructureorderPeer::IDSTRUCTURE, $value));
    }

    $criteria->add($criterion);
  }

  public function getModelName()
  {
    return 'Clientorder';
  }

  public function getFields()
  {
    return array(
      'idOrder'                  => 'Number',
      'orderName'                => 'Text',
      'textCategoryId'           => 'ForeignKey',
      'targetGroupId'            => 'ForeignKey',
      'formalStyleId'            => 'ForeignKey',
      'personStyleId'            => 'ForeignKey',
      'emotionStyleId'           => 'ForeignKey',
      'formulateId'              => 'ForeignKey',
      'excludedWords'            => 'Text',
      'urlImage'                 => 'Text',
      'created_at'               => 'Date',
      'expires_at'               => 'Date',
      'updated_at'               => 'Date',
      'editionoptionsorder_list' => 'ManyKey',
      'optionalgroupsorder_list' => 'ManyKey',
      'ordermedia_list'          => 'ManyKey',
      'structureorder_list'      => 'ManyKey',
    );
  }
}
